import './assets/main.css'

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import piniaPluginPersist from 'pinia-plugin-persist'
// 引入 Element Plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import permission from '@/directives/permission'

const app = createApp(App)
app.directive('permission', permission)
const pinia = createPinia()
pinia.use(piniaPluginPersist)
app.use(pinia)
// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// 添加Firefox渲染优化
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1
if (isFirefox) {
  // 在文档头部添加Firefox优化的meta标签
  const meta = document.createElement('meta')
  meta.name = 'viewport'
  meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'
  document.getElementsByTagName('head')[0].appendChild(meta)
  
  // 添加CSS变量到根元素
  document.documentElement.style.setProperty('--firefox-transform', 'translateZ(0)')
}

app.use(router)
app.use(ElementPlus, {
    locale: zhCn,
})

app.mount('#app')
